<template>
	<view class="wrap">
		<js-lang title="msg.title"></js-lang>
		<view class="search"><u-search v-model="keywords" @custom="search" @search="search" @clear="clear"></u-search></view>
		<scroll-view class="scroll-list" scroll-y="true">
			<u-collapse class="box" :accordion="false" :arrow="false">
				<view class="item" v-for="(item, index) in list" :key="item.code">
					<!-- <u-collapse-item :open="true">
					     
						<u-cell-group class="list" :border="false">
							<u-cell-item :arrow="false"  @click="navTo('/pages/sys/msg/form')">
								<text slot="title">{{item.type}}:{{item.msgContentEntity.content}}</text>
								<text slot="label">发送者：{{item.sendUserNamee}} | 时间：{{item.planpushdate}}</text>
							</u-cell-item>
						</u-cell-group>
					</u-collapse-item> -->
					<u-cell-item :arrow="false" style="padding-left: 10rpx; padding-right: 10rpx" :borderBottom="false" @click="navTo('/pages/sys/msg/form?id=' + item.id, item)">
						<text slot="title" class="u-line-1 content-span ">
							
							{{ item.type }}:{{  item.msgContentEntity.content }}
						</text>
						<text slot="label">发送者：{{ item.sendUserName }} | 时间：{{ item.planPushDate }}</text>
					</u-cell-item>
					
				</view>
			</u-collapse>
		</scroll-view>
	</view>
</template>
<script>
/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
export default {
	data() {
		return {
			keywords: '',
			query: {},
			list: [],
			yiArr:[]
		};
	},
	// onLoad() {
	// 	this.getList();
	// },
	// 监听页面显示。页面每次出现在屏幕上都触发，包括从下级页面点返回露出当前页面
	onShow() {
		this.getList();
	},
	methods: {
		getList() {
			let queryD = {
				msgContent: this.keywords,
				pageNo: 0
			};
			this.list=[];
			// 先查询待办消息
			this.$u.api.message.list(queryD).then(res => {
				
				if (!res.list || res.list.length == 0) {
					this.loadStatus = 'nomore';
					return;
				}
				for (var i = 0; i < res.list.length; i++) {
					res.list[i].type = '待办';
					this.list.push(res.list[i])
				}
				let queryy = {
					msgContent: this.keywords,
					pushed: true,
					pageNo: 0
				};
				// 再查询已办消息
				this.query.pushed = 'true';
				this.$u.api.message.list(queryy).then(res => {
					
					if (!res.list || res.list.length == 0) {
						this.loadStatus = 'nomore';
						return;
					}
					for (var i = 0; i < res.list.length; i++) {
						res.list[i].type = '已办';
						this.list.push(res.list[i])
						
					}
				});
			});
			
		},
		navTo(url, item) {
			// this.$u.api.message.readMsg({ id: item.id }).then(res => {
			// });
			uni.navigateTo({
				url: url
			});
		},
		search(value) {
			this.keywords = value;
			this.list = [];
			this.query.pageNo = 0;
			this.getList();
		},
		clear() {
			this.keywords = '';
			this.list = [];
			this.query.pageNo = 0;
			this.getList();
		}
	}
};
</script>
<style lang="scss">
page {
	background-color: #f8f8f8;
}
.content-span{
	 letter-spacing:1px;
}
.u-cell{
	display: block!important;
}
</style>
